﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace Vibz.Game.Bugs.Model
{
    [Serializable]
    [XmlType(TypeName = "pw")]
    public class Power : GroundObject
    {
        PowerType _Type;
        [XmlElement("pt")]
        public PowerType Type { get { return _Type; } set { _Type = value; NotifyValueChanged("Type", value); } }

        DateTime _StartTime;
        [XmlElement("st")]
        public DateTime StartTime { get { return _StartTime; } set { _StartTime = value; NotifyValueChanged("StartTime", value); } }

        int _Duration;
        [XmlElement("d")]
        public int Duration { get { return _Duration; } set { _Duration = value; NotifyValueChanged("Duration", value); } }

        [XmlIgnore()]
        public int RemainingSeconds { get { return this.Duration - (int)DateTime.Now.Subtract(this.StartTime).TotalSeconds; } }

        public Power() { }
        public Power(Ground gnd, PowerType type) : base(gnd)
        {
            Type = type;
            StartTime = DateTime.Now;
            Duration = 60;
        }
        public override void MergeOnPlayer(Player player)
        {
            player.Powers.Add(this);
            player.Score += (int)Type;
        }
    }
}
